#!/bin/bash
set -o errexit


# 安装数据库
#175.27.189.217  ubuntu/Qiuwen123456


# 系统信息
# root@u2duckdb:/opt# lsb_release -a
# No LSB modules are available.
# Distributor ID: Ubuntu
# Description:    Ubuntu 22.04.4 LTS
# Release:        22.04
# Codename:       jammy

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

sudo apt install -y  curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt update
sudo apt -y install postgresql-16



# sudo sh -c 'echo "deb https://mirrors.bfsu.edu.cn/postgresql/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# wget --quiet -O - https://mirrors.bfsu.edu.cn/postgresql/repos/apt/ACCC4CF8.asc | sudo apt-key add -
# sudo apt-get update
# sudo apt-get install postgresql-12 -y
# sudo service postgresql status

# sudo su postgres

# sudo passwd postgres

# psql

# #CREATE USER postgres WITH PASSWORD 'qiuwen123456'
# ALTER USER postgres WITH PASSWORD 'qiuwen123456'
# #  调整数据库性能参数
# /etc/postgresql/12/main/postgresql.conf
# /etc/postgresql/12/main/pg_hba.conf

# sudo service postgresql restart
# sudo service postgresql status

# # 查看服务器内存
# cat /proc/meminfo

# # 安装nginx
# sudo apt-get update
# sudo apt-get install nginx -y
# apt-cache policy nginx
# #http://175.27.189.217
# #http://175.27.189.217:8000
# #https://m.51ping.cn/
# #https://s.odoodemo.cn/
# # 配置ulimit -n

# /etc/security/limits.conf
# * hard nofile 102400
# * soft nofile 102400
# root hard nofile 102400
# root soft nofile 102400
# * hard nproc 102400
# * soft nproc 102400

# #修改内核
# echo "fs.file-max=102400" >>/etc/sysctl.conf
# sysctl -p

# # 安装supervisor
# #pip3 install supervisor
# apt-get install -y supervisor=4.1.0
# sudo supervisorctl tail pvs stderr
# tail -f /var/log/supervisor/supervisord.log

# virtualenvwrapper.sh
# ~/.bashrc
# export WORKON_HOME = $HOME/.envs
# source /usr/local/bin/virtualenvwrapper.sh
